<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: zhouzixiong1
  Date: 2017/8/31
  Time: 13:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户交易</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="../../statics/css/bootstrap.min.css" rel="stylesheet">
    <link href="../../statics/css/style.css" rel="stylesheet">
    <link href="../../statics/css/ASignInNormalUser.css" rel="stylesheet">
    <link href="../../statics/css/ATopMenu.css" rel="stylesheet">
    <script src="../../statics/js/jquery-3.0.0.js"></script>
    <script src="../../statics/js/layer.js"></script>
</head>
<body>
<div class="container">
    <div class="row">
        <div class="title aTopMenu">用户交易</div>
    </div>
    <div class="row aTopMenu">
        <c:import url="common/ATopMenu.jsp"></c:import>
    </div>
    <div class="row">
        <div class="col-sm-8 col-sm-push-2">
            <div class="row"><T2>用户充值</T2></div>
            <div class="col-sm-4 label">用户名：</div>
            <div class="col-sm-8">
                <input class="form-control" name="userName" id="userName" placeholder="请输入用户名"/>
            </div>
            <div class="col-sm-4 label">充值金额：</div>
            <div class="col-sm-8">
                <div class="input-group">
                    <input type="text" class="form-control" name="pay" id="pay" placeholder="请输入充值金额，精确到分(例：100.00)"/>
                    <span class="input-group-btn"><button class="btn btn-info" type="button" onclick="pay()">充值</button> </span>
                </div>
            </div>
            <div class="col-sm-4 label">消费金额：</div>
            <div class="col-sm-8">
                <div class="input-group">
                    <input type="text" class="form-control" name="consume" id="consume" placeholder="请输入交易金额，精确到分(例：100.00)"/>
                    <span class="input-group-btn"><button class="btn btn-info" type="button" onclick="consume()">消费</button> </span>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    document.getElementById("MenuAExchange").className = "active";
    function pay() {
        var pay = {
            userName: $("#userName").val(),
            jiaoyiMoney: $("#pay").val()
        }
        $.ajax({
            type: 'post',
            url: '/Money/pay',
            data: JSON.stringify(pay),
            contentType: 'application/json',
            dataType: 'json',
            success: function (data) {
                if(data.code!=0){
                    layer.msg(data.message);
                }
                layer.msg(data.data);
            }
        })
    }
    function consume() {
        var consume = {
            userName: $("#userName").val(),
            jiaoyiMoney:$("#consume").val()
        };
        $.ajax({
            type:'post',
            url:'/Money/consume',
            data: JSON.stringify(consume),
            contentType: 'application/json',
            dataType:'json',
            success:function (data) {
                if(data.code!="0"){
                    layer.msg(data.message);
                }
                else {
                    layer.msg(data.data);
                }
            }
        })
    }
</script>
</body>
</html>
